package adil.common.jfinal;

import adil.common.jfinal.model._MappingKit;
import adil.common.jfinal.plugin.acitiviti.ActivitiPlugin;
import com.jfinal.config.Constants;
import com.jfinal.config.Handlers;
import com.jfinal.config.Interceptors;
import com.jfinal.config.JFinalConfig;
import com.jfinal.config.Plugins;
import com.jfinal.config.Routes;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.template.Engine;

/**
* @author Adil_李园
* @version 2017年10月31日 14:46:02
* JFinal核心配置
*/
public class AdilConfig extends JFinalConfig{

	@Override
	public void configConstant(Constants me) {

		PropKit.use("a_little_config.txt");
		//设置开发模式
		me.setDevMode(true);
		//404报错异常
//		me.setError404View("/error/404.html");
	}
	/***
	 * 数据库的配置
	 * @return
	 */
	public static DruidPlugin createDruidPlugin() {
		return new DruidPlugin(PropKit.get("jdbcUrl"), PropKit.get("user"), PropKit.get("password").trim());
	}
	
	@Override
	public void configRoute(Routes me) {
		me.add(new AdminRoutes());
	}

	@Override
	public void configEngine(Engine me) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configPlugin(Plugins me) {
		DruidPlugin druidPlugin = createDruidPlugin();
		me.add(druidPlugin);

		ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
		_MappingKit.mapping(arp);
		me.add(arp);
		ActivitiPlugin acitivitiPlugin = new ActivitiPlugin();
		me.add(acitivitiPlugin);
	}

	@Override
	public void configInterceptor(Interceptors me) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void configHandler(Handlers me) {
		// TODO Auto-generated method stub
		
	}

}
